package com.tengfei.ui_widget;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

import androidx.appcompat.app.AppCompatActivity;

public class ButtonActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btnDisplay;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_button);
        getSupportActionBar().setTitle("ButtonAndImageButton");
        findViewById(R.id.btn_test1).setOnClickListener(this);
        findViewById(R.id.btn_test2).setOnClickListener(this);
        findViewById(R.id.ib_test3).setOnClickListener(this);
        btnDisplay = findViewById(R.id.btn_display);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_test1:
            case R.id.btn_test2:
                btnDisplay.setText(((Button)v).getText());
                break;
            case R.id.ib_test3:
                btnDisplay.setTextSize(30.0f);
                btnDisplay.setText(((ImageButton)v).getContentDescription());
                break;
        }
    }
}